package com.openlab.homeAdapter;

import java.util.ArrayList;
import java.util.Map;

import com.openlab.activity.R;
import com.openlab.util.Constant;
import com.openlab.util.RecommendForum;
import com.openlab.util.bean.TopThread;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class RecommendForumListAdapter extends BaseAdapter{
	    private LayoutInflater mInflater;
		private Context context;
		
		public RecommendForumListAdapter(Context context){
			mInflater = LayoutInflater.from(context);
		}
		
		@Override
		public int getCount() {
			return Constant.RECOMMENT_FORUM.length;
		}

		@Override
		public Object getItem(int position) {
			return Constant.RECOMMENT_FORUM[position];
		}

		@Override
		public long getItemId(int position) {
			return position;
		}
		
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {  
			 // A ViewHolder keeps references to children views to avoid unneccessary calls
            // to findViewById() on each row.
            ViewHolder holder;

            // When convertView is not null, we can reuse it directly, there is no need
            // to reinflate it. We only inflate a new View when the convertView supplied
            // by ListView is null.
            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.home_recommend_forum_list, null);

                // Creates a ViewHolder and store references to the two children views
                // we want to bind data to.
                holder = new ViewHolder();
                holder.text = (TextView) convertView.findViewById(R.id.forum_name);
                holder.icon = (ImageView) convertView.findViewById(R.id.forum_icon);

                convertView.setTag(holder);
            } else {
                // Get the ViewHolder back to get fast access to the TextView
                // and the ImageView.
                holder = (ViewHolder) convertView.getTag();
            }

            // Bind the data efficiently with the holder.
            holder.text.setText(Constant.RECOMMENT_FORUM[position]);
//            holder.icon.setImageBitmap((position & 1) == 1 ? mIcon1 : mIcon2);

            return convertView;
			
		}
		
        static class ViewHolder {
            TextView text;
            ImageView icon;
        }

	}
